package ai4games_tests.soccer;

import game2dai.World;
import game2dai.entities.BaseEntity;
import game2dai.fsm.State;
import game2dai.fsm.Telegram;

public class KeeperGlobal extends State implements Constants {

	private static KeeperGlobal instance = null;
	
	public static KeeperGlobal state(){
		if(instance == null){
			instance = new KeeperGlobal();
			instance.name = "Keeper global";
		}
		return instance;
	}
	
	@Override
	public void enter(BaseEntity owner) {
	}

	@Override
	public void execute(BaseEntity owner, double deltaTime, World world) {
	}

	@Override
	public void exit(BaseEntity owner) {
	}

	@Override
	public boolean onMessage(BaseEntity owner, Telegram tgram) {
		GoalKeeper keeper = (GoalKeeper) owner;
		switch(tgram.msg){
		case GO_TO_REGION:
			keeper.FSM().changeState(PlayerReturnToRegion.state());
			return true;
		case RECEIVE_BALL:
			keeper.FSM().changeState(KeeperInterceptBall.state());
			return true;
		case PLAYER_PREPARE_FOR_KICKOFF:
			keeper.FSM().changeState(PlayerPrepareForKickOff.state());
			return true;
		case TEND_GOAL:			
			keeper.FSM().changeState(KeeperTendGoal.state());
			break;
		}
		return false;
	}
	
	

}
